// import { request } from "http";
import { defineStore } from "pinia";
import request from '@/utils/request'
import {Profile} from '@/types/user'
import { ApiRes } from "@/types/data";
import {setProfile ,getProfile} from '@/utils/storage'
export default defineStore('user',{
    state() {
        return {
            profile:getProfile()// 个人信息
            
        }
    },
    actions:{
        // 用户名和密码登录
        async login(account:string,password:string) {
            const res = await request.post<ApiRes<Profile>>('/login',{
                account,
                password
            })
            // console.log(res)
            this.profile = res.data.result
            setProfile(res.data.result)
         }
        // 用户名验证码登录
    }
})